export const regPhone = (curVal) => {
	const reg = /^(12[3]|13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/
	const bool = reg.test(curVal)
	return bool ? '' : '手机号码格式不正确'
}
export const regSum = (curVal) => {
	const reg = /^-?[1-9][0-9]?.?[0-9]*$/
	const bool = reg.test(curVal)
	return bool ? '' : '请输入正确数量'
}
export const regNumber = (curVal) => {
	const reg = /^\d{3,20}$/;
	console.log(curVal)
	const bool = reg.test(curVal)
	return bool ? '' : '账户格式不正确'
}
export const regVerification = (curVal) => {
	const reg = /^\d{6}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '验证码不正确'
}
export const regCode = (curVal) => {
	const reg = /^\d{4}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '验证码不正确'
}

export const regPassword = (curVal) => {
	const reg = /^(\w){6,20}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '登录密码格式不正确'
}

export const regPassword2 = (curVal, curVal2) => {
	const bool = curVal == curVal2
	return bool ? '' : '两次登录密码输入不同'
}

export const regPayPassword = (curVal, pwd) => {
	pwd = pwd | null
	const reg = /^(\w){6,20}$/;
	console.log(curVal)
	const bool = reg.test(curVal)
	if (!curVal) {
		return '二级密码不能为空'
	}
	if (curVal == pwd) {
		return '二级密码和登录密码不能相同'
	}
	return bool ? '' : '二级密码格式不正确'
}

export const regPayPassword2 = (curVal, curVal2) => {
	const bool = curVal === curVal2
	return bool ? '' : '两次二级密码输入不同'
}

export const regInvite = (curVal) => {
	const reg = /^(12[3]|13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/
	const bool = reg.test(curVal)
	return bool ? '' : '邀请人手机号不正确'
}

export const regName = (curVal) => {
	const reg = /^[\w\u4e00-\u9fa5]{2,20}$/
	const bool = reg.test(curVal)
	return bool ? '' : '昵称格式不正确'
}
export const regRealName = (curVal) => {
	const reg = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/
	const bool = reg.test(curVal)
	return bool ? '' : '姓名格式不正确'
}
export const regIdCards = (curVal) => {
	const reg =
		/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/
	const bool = reg.test(curVal)
	return bool ? '' : '请输入正确的身份证号'
}

export const regBankCard = (curVal) => {
	const reg = /^([1-9]{1})(\d{14}|\d{18})$/
	const bool = reg.test(curVal)
	return bool ? '' : '请输入正确的银行卡号'
}


export const regSubmit = (verify) => {
	const pwd = verify.password || ''
	const PayPwd = verify.payPassword || ''
	for (let i in verify) {
		switch (i) {
			case 'realName':
				const rRealName= regRealName(verify[i])
				if (rRealName) return rRealName
				break;
			case 'nickName':
				const rName = regName(verify[i])
				if (rName) return rName
				break;
			case 'phone':
				const rPhone = regPhone(verify[i])
				if (rPhone) return rPhone
				break;
			case 'number':
				const rNumber = regNumber(verify[i])
				if (rNumber) return rNumber
				break;
			case 'verification':
				const rVerification = regVerification(verify[i])
				if (rVerification) return rVerification
				break;
			case 'code':
				const rCode = regCode(verify[i])
				if (rCode) return rCode
				break;
			case 'pwd':
			case 'password':
				const rPassword = regPassword(verify[i])
				if (rPassword) return rPassword
				break;
			case 'password2':
				const rPassword2 = regPassword2(verify[i], pwd)
				if (rPassword2) return rPassword2
				break;
			case 'payPassword':
				const pPassword = regPayPassword(verify[i], pwd)
				if (pPassword) return pPassword
				break;
			case 'payPassword2':
				const pPassword2 = regPayPassword2(verify[i], PayPwd)
				if (pPassword2) return pPassword2
				break;
			case 'invite':
				const rInvite = regInvite(verify[i])
				if (rInvite) return rInvite
				break;
			case 'idCards':
				const rIdCards = regIdCards(verify[i])
				if (rIdCards) return rIdCards
				break;
			case 'bankCard':
				const rBankCard = regBankCard(verify[i])
				if (rBankCard) return rBankCard
				break;
			default:

		}
	}
}

export const ifVerif = (verify) => {
	const arr = Object.values(this.verify);
	for (const i of arr) {
		if (!i) {
			this.active = false
			break
			return
		}
		this.active = i
	}

}
